<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:a4j="http://richfaces.org/a4j"
	template="/layout/template.xhtml">

	<ui:define name="pageLayout">
		Admin
		<a4j:form>
			<a4j:commandButton action="#{adminAction.startScan()}" value="start scan" />
		</a4j:form>
		<hr/>
		<a4j:form>
			<h:inputTextarea value="#{adminAction.sqlQuery}" cols="80" rows="8"/>
			<br/>
			<a4j:commandButton action="#{adminAction.runSql()}" value="run SQL" reRender="queryResultPanel"/>
			<br/>
			
		</a4j:form>
		
		<a4j:outputPanel id="queryResultPanel">
			<ui:fragment
				rendered="#{adminAction.tableColumns != null and adminAction.tableColumns.size > 0}">
				<table>
					<thead>
						<tr>
							<ui:repeat var="column" value="#{adminAction.tableColumns}">
								<th>
									#{column.name}
									<br/>
									#{column.type}
								</th>
							</ui:repeat>
						</tr>
					</thead>
					<tbody>
						<ui:fragment
							rendered="#{adminAction.tableResults != null and adminAction.tableResults.size > 0}">
							<ui:repeat var="row" value="#{adminAction.tableResults}">
								<tr>
									<ui:repeat var="cell" value="#{row}">
										<td>
											#{cell}
										</td>
									</ui:repeat>
								</tr>
							</ui:repeat>
						</ui:fragment>
					</tbody>
				</table>
			</ui:fragment>	
		</a4j:outputPanel>
	</ui:define>

</ui:composition>